package com.hsylient.javase.chapter11.demo09;

public class ThreadPriority {

    public static void main(String[] args) {
        Thread thread = new Thread(() -> {
            System.out.println(Thread.currentThread().getName() + "的优先级为: " + Thread.currentThread().getPriority());
        });
        Thread thread2 = new Thread(() -> {
            System.out.println(Thread.currentThread().getName() + "的优先级为: " + Thread.currentThread().getPriority());
        });
        Thread thread3 = new Thread(() -> {
            System.out.println(Thread.currentThread().getName() + "的优先级为: " + Thread.currentThread().getPriority());
        });

        thread.setPriority(Thread.MIN_PRIORITY);
        thread.start();
        thread2.setPriority(Thread.NORM_PRIORITY);
        thread2.start();
        thread3.setPriority(Thread.MAX_PRIORITY);
        thread3.start();

        System.out.println("主线程的优先级是：" + Thread.currentThread().getPriority());

    }

}
